﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VideoCache.Server.Model;
using DbMapping.Common;
using VideoCache.Server.DAL;

namespace VideoCache.Server.BLL
{
    public partial class NetbarBLL
    {
        public static NetbarInfo GetNetbarByUserId(int userId)
        {
            Conditions cons = new Conditions();

            cons.Add(new ConditionItem(LinkType.And, NetbarInfo.UserIdField, CompareType.Equal, userId));

            NetbarInfo netbar = NetbarDAL.Find(cons, null);

            if (netbar == null) throw new ArgumentException("网吧不存在。");

            return NetbarDAL.Find(cons, null);
        }

        public static NetbarInfo GetNetbarByUserName(string userName)
        {
            UserInfo info = UserBLL.GetUserByName(userName);

            return GetNetbarByUserId(info.Id);
        }
    }
}
